package com.flame.shapeville.component.task1.shape3D;

import javafx.scene.paint.Color;
import javafx.scene.shape.MeshView;
import javafx.scene.shape.TriangleMesh;

/**
 * Represents a tetrahedron used in Task 1.
 * <p>
 * A tetrahedron is a polyhedron composed of four triangular faces.
 *
 * @author Flame Dev Team
 * @version 1.0
 * @since 2025-05-12
 */
public class JfTetrahedron extends JfShape3D {

    /**
     * Constructs a new tetrahedron with the specified size.
     *
     * @param size the bounding box size for the tetrahedron
     */
    public JfTetrahedron(double size) {
        super(size);

        TriangleMesh mesh = new TriangleMesh();

        float x1 = 0, y1 = 0, z1 = 0;
        float x2 = 0, y2 = (float) size, z2 = -(float) size;
        float x3 = (float) size, y3 = (float) size, z3 = 0;
        float x4 = (float) size, y4 = 0, z4 = -(float) size;

        mesh.getPoints().addAll(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);

        mesh.getTexCoords().addAll(0.0f, 0.0f);

        mesh.getFaces().addAll(
                0, 0, 2, 0, 1, 0,
                0, 0, 3, 0, 2, 0,
                1, 0, 3, 0, 0, 0,
                2, 0, 3, 0, 1, 0
        );

        shape = new MeshView(mesh);
        initBaseParams(Color.CYAN);
    }
}
